using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using BUS;
using Utility;
public partial class Admin_CapNhatNhanVien : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadData();
        }
    }

    private void LoadData()
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"]);

            tbNhanVienEntities nhanVien = tbNhanVienBUS.GetByID(id);
            txt_MaNV.Text = nhanVien.MaNV.ToString();
            txt_TenNV.Text = nhanVien.TenNV.ToString();           
            txt_DiaChi.Text = nhanVien.DiaChi.ToString();
            txt_DienThoai.Text = nhanVien.DienThoai.ToString();
            txt_email.Text = nhanVien.Email.ToString();
        }
        catch
        {
            Response.Redirect("~/Admin/DanhSachNhanVien.aspx");
        }

    }
    protected void btn_Add_Click(object sender, EventArgs e)
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            tbNhanVienEntities nhanVien = tbNhanVienBUS.GetByID(id);
            nhanVien.TenNV = txt_TenNV.Text;          
            nhanVien.DiaChi = txt_DiaChi.Text;
            nhanVien.DienThoai = txt_DienThoai.Text;
            nhanVien.Email = txt_email.Text;
            tbNhanVienBUS.Update(nhanVien);
            Response.Redirect("~/Admin/DanhSachNhanVien.aspx");
        }
        catch
        {
            Response.Redirect("~/Admin/DanhSachNhanVien.aspx");
        }
        Response.Redirect(Request.RawUrl);
    }
}
